<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - lcov.info.p - core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic/IsolationModeLogic.sol</title>
  <link rel="stylesheet" type="text/css" href="../../../../../../../../../../../gcov.css">
</head>

<body>

          <table width="100%" border=0 cellspacing=0 cellpadding=0>
            <tr><td class="title">LCOV - code coverage report</td></tr>
            <tr><td class="ruler"><img src="../../../../../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>

            <tr>
              <td width="100%">
                <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="10%" class="headerValue"><a href="../../../../../../../../../../../index.html">top level</a> - <a href="index.html">core/contracts/protocol/libraries/logic/src/core/contracts/protocol/libraries/logic</a> - IsolationModeLogic.sol<span style="font-size: 80%;"> (source / <a href="IsolationModeLogic.sol.func-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="5%"></td>
            <td width="5%" class="headerCovTableHead">Coverage</td>
            <td width="5%" class="headerCovTableHead" title="Covered + Uncovered code">Total</td>
            <td width="5%" class="headerCovTableHead" title="Exercised code only">Hit</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">lcov.info.p</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntryHi">100.0&nbsp;%</td>
            <td class="headerCovTableEntry">9</td>
            <td class="headerCovTableEntry">9</td>
          </tr>
          <tr>
            <td class="headerItem">Test Date:</td>
            <td class="headerValue">2024-04-09 14:12:28</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntryHi">100.0&nbsp;%</td>
            <td class="headerCovTableEntry">1</td>
            <td class="headerCovTableEntry">1</td>
          </tr>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td class="headerItem">Branches:</td>
            <td class="headerCovTableEntryHi">-</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">0</td>
          </tr>
                  <tr><td><img src="../../../../../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
                </table>
              </td>
            </tr>

            <tr><td class="ruler"><img src="../../../../../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
          </table>

          <table cellpadding=0 cellspacing=0 border=0>
            <tr>
              <td><br></td>
            </tr>
            <tr>
              <td>
<pre class="sourceHeading">             Branch data     Line data    Source code</pre>
<pre class="source">
<span id="L1"><span class="lineNum">       1</span>                 :             : // SPDX-License-Identifier: BUSL-1.1</span>
<span id="L2"><span class="lineNum">       2</span>                 :             : pragma solidity ^0.8.10;</span>
<span id="L3"><span class="lineNum">       3</span>                 :             : </span>
<span id="L4"><span class="lineNum">       4</span>                 :             : import {DataTypes} from '../types/DataTypes.sol';</span>
<span id="L5"><span class="lineNum">       5</span>                 :             : import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol';</span>
<span id="L6"><span class="lineNum">       6</span>                 :             : import {UserConfiguration} from '../configuration/UserConfiguration.sol';</span>
<span id="L7"><span class="lineNum">       7</span>                 :             : import {SafeCast} from '../../../dependencies/openzeppelin/contracts/SafeCast.sol';</span>
<span id="L8"><span class="lineNum">       8</span>                 :             : </span>
<span id="L9"><span class="lineNum">       9</span>                 :             : /**</span>
<span id="L10"><span class="lineNum">      10</span>                 :             :  * @title IsolationModeLogic library</span>
<span id="L11"><span class="lineNum">      11</span>                 :             :  * @author Aave</span>
<span id="L12"><span class="lineNum">      12</span>                 :             :  * @notice Implements the base logic for handling repayments for assets borrowed in isolation mode</span>
<span id="L13"><span class="lineNum">      13</span>                 :             :  */</span>
<span id="L14"><span class="lineNum">      14</span>                 :             : library IsolationModeLogic {</span>
<span id="L15"><span class="lineNum">      15</span>                 :             :   using ReserveConfiguration for DataTypes.ReserveConfigurationMap;</span>
<span id="L16"><span class="lineNum">      16</span>                 :             :   using UserConfiguration for DataTypes.UserConfigurationMap;</span>
<span id="L17"><span class="lineNum">      17</span>                 :             :   using SafeCast for uint256;</span>
<span id="L18"><span class="lineNum">      18</span>                 :             : </span>
<span id="L19"><span class="lineNum">      19</span>                 :             :   // See `IPool` for descriptions</span>
<span id="L20"><span class="lineNum">      20</span>                 :             :   event IsolationModeTotalDebtUpdated(address indexed asset, uint256 totalDebt);</span>
<span id="L21"><span class="lineNum">      21</span>                 :             : </span>
<span id="L22"><span class="lineNum">      22</span>                 :             :   /**</span>
<span id="L23"><span class="lineNum">      23</span>                 :             :    * @notice updated the isolated debt whenever a position collateralized by an isolated asset is repaid or liquidated</span>
<span id="L24"><span class="lineNum">      24</span>                 :             :    * @param reservesData The state of all the reserves</span>
<span id="L25"><span class="lineNum">      25</span>                 :             :    * @param reservesList The addresses of all the active reserves</span>
<span id="L26"><span class="lineNum">      26</span>                 :             :    * @param userConfig The user configuration mapping</span>
<span id="L27"><span class="lineNum">      27</span>                 :             :    * @param reserveCache The cached data of the reserve</span>
<span id="L28"><span class="lineNum">      28</span>                 :             :    * @param repayAmount The amount being repaid</span>
<span id="L29"><span class="lineNum">      29</span>                 :             :    */</span>
<span id="L30"><span class="lineNum">      30</span>                 :<span class="tlaGNC tlaBgGNC">       11036 :   function updateIsolatedDebtIfIsolated(</span></span>
<span id="L31"><span class="lineNum">      31</span>                 :             :     mapping(address =&gt; DataTypes.ReserveData) storage reservesData,</span>
<span id="L32"><span class="lineNum">      32</span>                 :             :     mapping(uint256 =&gt; address) storage reservesList,</span>
<span id="L33"><span class="lineNum">      33</span>                 :             :     DataTypes.UserConfigurationMap storage userConfig,</span>
<span id="L34"><span class="lineNum">      34</span>                 :             :     DataTypes.ReserveCache memory reserveCache,</span>
<span id="L35"><span class="lineNum">      35</span>                 :             :     uint256 repayAmount</span>
<span id="L36"><span class="lineNum">      36</span>                 :             :   ) internal {</span>
<span id="L37"><span class="lineNum">      37</span>                 :<span class="tlaGNC">       33108 :     (bool isolationModeActive, address isolationModeCollateralAddress, ) = userConfig</span></span>
<span id="L38"><span class="lineNum">      38</span>                 :             :       .getIsolationModeState(reservesData, reservesList);</span>
<span id="L39"><span class="lineNum">      39</span>                 :             : </span>
<span id="L40"><span class="lineNum">      40</span>                 :<span class="tlaGNC">       11036 :     if (isolationModeActive) {</span></span>
<span id="L41"><span class="lineNum">      41</span>                 :<span class="tlaGNC">           4 :       uint128 isolationModeTotalDebt = reservesData[isolationModeCollateralAddress]</span></span>
<span id="L42"><span class="lineNum">      42</span>                 :             :         .isolationModeTotalDebt;</span>
<span id="L43"><span class="lineNum">      43</span>                 :             : </span>
<span id="L44"><span class="lineNum">      44</span>                 :<span class="tlaGNC">           6 :       uint128 isolatedDebtRepaid = (repayAmount /</span></span>
<span id="L45"><span class="lineNum">      45</span>                 :             :         10 **</span>
<span id="L46"><span class="lineNum">      46</span>                 :             :           (reserveCache.reserveConfiguration.getDecimals() -</span>
<span id="L47"><span class="lineNum">      47</span>                 :             :             ReserveConfiguration.DEBT_CEILING_DECIMALS)).toUint128();</span>
<span id="L48"><span class="lineNum">      48</span>                 :             : </span>
<span id="L49"><span class="lineNum">      49</span>                 :             :       // since the debt ceiling does not take into account the interest accrued, it might happen that amount</span>
<span id="L50"><span class="lineNum">      50</span>                 :             :       // repaid &gt; debt in isolation mode</span>
<span id="L51"><span class="lineNum">      51</span>                 :<span class="tlaGNC">           4 :       if (isolationModeTotalDebt &lt;= isolatedDebtRepaid) {</span></span>
<span id="L52"><span class="lineNum">      52</span>                 :<span class="tlaGNC">           2 :         reservesData[isolationModeCollateralAddress].isolationModeTotalDebt = 0;</span></span>
<span id="L53"><span class="lineNum">      53</span>                 :<span class="tlaGNC">           2 :         emit IsolationModeTotalDebtUpdated(isolationModeCollateralAddress, 0);</span></span>
<span id="L54"><span class="lineNum">      54</span>                 :             :       } else {</span>
<span id="L55"><span class="lineNum">      55</span>                 :<span class="tlaGNC">           3 :         uint256 nextIsolationModeTotalDebt = reservesData[isolationModeCollateralAddress]</span></span>
<span id="L56"><span class="lineNum">      56</span>                 :             :           .isolationModeTotalDebt = isolationModeTotalDebt - isolatedDebtRepaid;</span>
<span id="L57"><span class="lineNum">      57</span>                 :<span class="tlaGNC">           2 :         emit IsolationModeTotalDebtUpdated(</span></span>
<span id="L58"><span class="lineNum">      58</span>                 :             :           isolationModeCollateralAddress,</span>
<span id="L59"><span class="lineNum">      59</span>                 :             :           nextIsolationModeTotalDebt</span>
<span id="L60"><span class="lineNum">      60</span>                 :             :         );</span>
<span id="L61"><span class="lineNum">      61</span>                 :             :       }</span>
<span id="L62"><span class="lineNum">      62</span>                 :             :     }</span>
<span id="L63"><span class="lineNum">      63</span>                 :             :   }</span>
<span id="L64"><span class="lineNum">      64</span>                 :             : }</span>
        </pre>
              </td>
            </tr>
          </table>
          <br>

          <table width="100%" border=0 cellspacing=0 cellpadding=0>
            <tr><td class="ruler"><img src="../../../../../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
            <tr><td class="versionInfo">Generated by: <a href="https://github.com//linux-test-project/lcov" target="_parent">LCOV version 2.0-1</a></td></tr>
          </table>
          <br>

</body>
</html>
